class BaseLine
    attr_accessor :x, :filter
    attr_reader   :name, :type
    def initialize(name, range, type, filter = nil)
        @name     = name
        @range    = range
        @type     = type
        @filter   = filter
        @x        = 0.0
    end

    def display
       glBegin(GL_QUADS);
          glVertex(@x+0.0, 0.0, 0.0);
          glVertex(@x+0.01, 0.0, 0.0);
          glVertex(@x+0.01, 1.0, 0.0);
          glVertex(@x+0.0, 1.0, 0.0);
       glEnd();

       glRasterPos2f(@x, 1.1)
       @name.each_byte{|x| GLUT.BitmapCharacter(0, x) }

    end

    def value_to_pos(value)
       case value.class.to_s
       when "Pcap::IPAddress"
           value = value.to_i
       when "Fixnum"
           value = value.to_i
       when "FalseClass"
           if value
               value = 1
           else
               value = 0
           end
       when "TrueClass"
           if value
               value = 1
           else
               value = 0
           end

       else
           pp value.class
       end


       if filter && value <= @filter[0]
           return 0.0 
       elsif filter && value >= @filter[1]
           return 1.0
       elsif filter
           slice = 1.0/(@filter[1]-@filter[0])
           (value-@filter[0]) * slice
       else
           slice = 1.0/(@range[1]-@range[0])
           (value-@range[0])  * slice
#           @range[0]+((1.0/@range[1])*value.to_i)
       end
    end
end

